{% extends "user/base-users-table.html" %}

{% block after_rank_head %}
    {% if has_rating %}
        <th class="rating-column">{{ _('Rating') }}</th>
    {% endif %}
    <th class="organization-column">{{ _('Organization') }}</th>
{% endblock %}

{% block after_rank %}
    {% if has_rating %}
        <td class="rating-column">{% if user.participation_rating %}{{ rating_number(user.participation_rating) }}{% endif %}</td>
    {% endif %}
    <td class="organization-column">
        {% if user.organization %}
            <span class="organization"><a href="{{ user.organization.get_absolute_url() }}">
                {{- user.organization.short_name -}}
            </a></span>
        {% endif %}
    </td>
{% endblock %}

{% block user_data %}
    {% if not contest.ended %}
        {% if not user.participation.ended %}
            <div class="start-time active">
                {% with abs=_('Started on {time}'), rel=_('Started {time}') %}
                    {{ relative_time(user.participation.start, abs=abs, rel=rel) }}
                {% endwith %}
            </div>
        {% else %}
            <div class="start-time">{{ _('Participation ended.') }}</div>
        {% endif %}
    {% endif %}

    {% if can_edit %}
        <span class="contest-participation-operation">
            <form action="{{ url('contest_participation_disqualify', contest.key) }}" method="post">
                {% csrf_token %}
                <input type="hidden" name="participation" value="{{ user.participation.id }}">
                {% if user.participation.is_disqualified %}
                    <a href="#" title="{{ _('Un-Disqualify') }}"
                       class="un-disqualify-participation"><i class="fa fa-undo fa-fw"></i></a>
                {% else %}
                    <a href="#" title="{{ _('Disqualify') }}"
                       class="disqualify-participation"><i class="fa fa-trash fa-fw"></i></a>
                {% endif %}
            </form>
            {% if perms.judge.change_contestparticipation %}
                <a href="{{ url('admin:judge_contestparticipation_change', user.participation.id) }}"
                   title="{{ _('Admin') }}" class="edit-participation"><i class="fa fa-cog fa-fw"></i></a>
            {% endif %}
        </span>
    {% endif %}
{% endblock %}

{% block before_point_head %}
    {% for problem in problems %}
        <th class="points header"><a href="{{ url('contest_ranked_submissions', contest.key, problem.problem.code) }}">
            {{- contest.get_label_for_problem(loop.index0) }}
            <div class="point-denominator">{{ problem.points }}</div>
        </a></th>
    {% endfor %}
{% endblock %}

{% block row_extra %}
    {% if user.participation.is_disqualified %}
        class="disqualified"
    {% endif %}
{% endblock %}

{% block before_point %}
    {% for cell in user.problem_cells %}
        {{ cell }}
    {% endfor %}
{% endblock %}

{% block point %}
    {{ user.result_cell }}
{% endblock %}
